# _*_ coding : utf-8 _*_
# @Time : 2022/9/12 15:59
# @Author : 软柠柠吖
# @File : 04-字符串替换案例
# @Project : pythonProject

import xlrd
from xlutils.copy import copy

wb = xlrd.open_workbook(r'D:\桌面\test\test.xlsx')
ws = wb.sheet_by_name('员工表')

nwb = copy(wb)
nws = nwb.get_sheet('员工表')

for row_num in range(1, ws.nrows):
    txt = ws.cell_value(row_num, 1)
    # txt = txt.replace('、', '-').replace('\\', '-').replace('|', '-')

    for symbol in r'\、|':
        txt = txt.replace(symbol, '-')
    nws.write(row_num, 2, txt)
nwb.save(r'D:\桌面\test\test.xlsx')